Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add upload to registry workflow for foundry_std #2461

Open
wants to merge 29 commits into
base: master
Choose a base branch
from

Conversation

THenry14
Copy link
Contributor

@THenry14 THenry14 commented Sep 11, 2024

Closes #2344

This PR is a part of the stack:
-- Add missing info recommended for package uploads (#2460)
--> Add github action workflow for automatic registry uploads during release (This PR)

Introduced changes

  • Updates github workflow to also upload std libraries to scarbs registry during release
  • Sets snforge_scarb_plugin to specific version downloadable from the registry, as required by scarb

Checklist

  • Linked relevant issue
  • Updated relevant documentation
  • Added relevant tests
  • Performed self-review of the code
  • Added changes to CHANGELOG.md

@franciszekjob
Copy link
Collaborator

Blocked by software-mansion/scarb#1605

github-merge-queue bot pushed a commit that referenced this pull request Oct 11, 2024
<!-- Reference any GitHub issues resolved by this PR -->

Related to #2344

This PR is a part of the stack:
--> Add missing info recommended for package uploads (This PR)
-- Add github action workflow for automatic registry uploads during
release (#2461)

## Introduced changes

<!-- A brief description of the changes -->

- Adds readmes and links to respective Scarb.tomls, so to view this
metadata on the registry and supress scarb warnings
- Bump snforge_scarb_plugin version to `0.31.0`, to properly reflect its
version in regards to the registry. **From now on all changes made to
this crate should be concluded with version bump**

## Checklist

<!-- Make sure all of these are complete -->

- [X] Linked relevant issue
- [X] Updated relevant documentation
- [X] Added relevant tests
- [X] Performed self-review of the code
- [X] Added changes to `CHANGELOG.md`

---------

Co-authored-by: Fiiranek <[email protected]>
Co-authored-by: Franciszek Job <[email protected]>
Base automatically changed from szymczyk/registry to master October 11, 2024 16:12
@kkawula kkawula self-assigned this Nov 4, 2024
@kkawula
Copy link
Collaborator

kkawula commented Nov 4, 2024

It needs clarification, but plugins weren't correctly handled by scarb until software-mansion/scarb#1712 was merged, I suppose that it will be needed to update scarb version in the entire project.
In the earlier versions scarb had problem with access to the cache in database which caused dead lock.
CI to lookup: https://github.com/foundry-rs/starknet-foundry/actions/runs/11577774705

edit: The scarb version in the project can probably stay as it is but while package upload dependency in snforge_std/Scarb.toml should be manually switched to registry dependency and after upload reverted.

@maciektr
Copy link
Contributor

maciektr commented Nov 4, 2024

It needs clarification, but plugins weren't correctly handled by scarb until software-mansion/scarb#1712 was merged, I suppose that it will be needed to update scarb version in the entire project.

It shouldn't have anything to do with uploading packages though

working-directory: snforge_std
run: |
../scripts/set_plugin_version.sh
scarb publish --allow-dirty
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--allow-dirty because we modify snforge_std by executing the script without committing changes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not require from tag that triggers the workflow to already include changes introduced by set_plugin_version.sh? 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For development reason, we always would like to have a relative path specified in the dependency

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a hard requirement to set the version in snforge only for uploads? What are the downsides of having this set in repo?

@kkawula
Copy link
Collaborator

kkawula commented Nov 13, 2024

it works, tested on dev registry.

@kkawula kkawula marked this pull request as ready for review November 13, 2024 11:10
@kkawula kkawula marked this pull request as draft November 13, 2024 11:42
Copy link
Contributor

@DelevoXDG DelevoXDG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial review, please re-request when ready 👍🏻

# todo: Use scarb stable version that support publishing plugins (after 2.8.4)
scarb-version: "nightly-2024-11-09"

- name: Check if package version exist in the registry
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this step necessary?

We implemented this for publishing Scarb plugins because their version matches the Cairo version. Since multiple Scarb versions can correspond to a single Cairo version, running the workflow with every Scarb release could cause errors by publishing plugins with the same version.

Afaik, this doesn’t apply to snfoundry plugins because their version isn’t tied to any Cairo version. Normally, the workflow should only be triggered once per tag.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might decouple foundry plugin version from foundry itself so it might be the case that for consecutive foundry releases, plugin version will stay the same.

So we have to make sure we don't reupload the plugin to the registry in these cases.

Copy link
Collaborator

@kkawula kkawula Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes we patch plugin, without release then we would like to publish it and sometimes we will not do release plugin together with snforge_std and sncast_std, we want to set it on 1.0.0 and keep it until there are changes, and then it would fail the workflow and CI will be red at the release

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I pointed out offline, if you're going in the direction of decoupling plugin from foundry itself, it seems to me it a separate workflow should be considered

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is one of the opportunities, but isn't it good enough? @cptartur

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As on how the decoupling will go exactly is yet to be determined. I think the workflow in the current form is okay, and we can introduce changes in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly to @DelevoXDG , I would probably be in favour of splitting release flows for macros and standard libraries as well.

My understanding is that the plugin won't necessarily follow the *_std version, so it may make sense to release it independently. For this manual workflow dispatch only is good enough. Most of logic from this file is fine, though you wouldn't need anything from this step (I mean the check-versions, which I find very hacky) so I'd actually argue it could become far simpler.

Having this, we could probably incorporate *_std upload to the release.yml workflow, as it seems to me this is more natural place for this. We already verify the version there, so chances are we do not need any further modifications - we could probably just add a new job (standard-libraries-release, or scarbs-release or sth) that will set the plugin version (this is unnecessary if you decide to set the version in Scarb.toml in repo) and use scarb to publish and call it a day. No need to check versions against the registry, verify what should/should not be published etc.

Thoughts?

.github/workflows/publish_packages.yml Show resolved Hide resolved
on:
release:
types:
- published
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think published will also trigger on creating a draft release which our workflow does. I think it should be released so it only uploads to registry if we publish a new release.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also a concern, in case we ever create a pre-release, do we want to upload to registry as well? Does it support pre-release versions?

cc @maciektr

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@maciektr maciektr Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image image

Afaik published is triggered when you publish a draft - regardless of whether it's pre-release or release.
image

released differentiates between pre-release and full release.

in case we ever create a pre-release, do we want to upload to registry as well

Why not? 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, if we want to upload pre-releases as well, let's keep it at published.

.github/workflows/publish_packages.yml Show resolved Hide resolved
# todo: Use scarb stable version that support publishing plugins (after 2.8.4)
scarb-version: "nightly-2024-11-09"

- name: Check if package version exist in the registry
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might decouple foundry plugin version from foundry itself so it might be the case that for consecutive foundry releases, plugin version will stay the same.

So we have to make sure we don't reupload the plugin to the registry in these cases.

.github/workflows/publish_packages.yml Outdated Show resolved Hide resolved
scripts/set_plugin_version.sh Outdated Show resolved Hide resolved
scripts/set_plugin_version.sh Show resolved Hide resolved
@kkawula kkawula marked this pull request as ready for review November 13, 2024 13:54
Copy link
Member

@cptartur cptartur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@THenry14 Can you please review as well? I know it's technically your PR but it's changed a bit 😅

on:
release:
types:
- released
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the discussion from different comment

Suggested change
- released
- published

.github/workflows/publish_packages.yml Show resolved Hide resolved
# todo: Use scarb stable version that support publishing plugins (after 2.8.4)
scarb-version: "nightly-2024-11-09"

- name: Check if package version exist in the registry
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly to @DelevoXDG , I would probably be in favour of splitting release flows for macros and standard libraries as well.

My understanding is that the plugin won't necessarily follow the *_std version, so it may make sense to release it independently. For this manual workflow dispatch only is good enough. Most of logic from this file is fine, though you wouldn't need anything from this step (I mean the check-versions, which I find very hacky) so I'd actually argue it could become far simpler.

Having this, we could probably incorporate *_std upload to the release.yml workflow, as it seems to me this is more natural place for this. We already verify the version there, so chances are we do not need any further modifications - we could probably just add a new job (standard-libraries-release, or scarbs-release or sth) that will set the plugin version (this is unnecessary if you decide to set the version in Scarb.toml in repo) and use scarb to publish and call it a day. No need to check versions against the registry, verify what should/should not be published etc.

Thoughts?


PLUGIN_FILE_PATH="../crates/snforge-scarb-plugin/Scarb.toml"

VERSION=$(cat "$PLUGIN_FILE_PATH" | grep version | cut -d '"' -f 2)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

working-directory: snforge_std
run: |
../scripts/set_plugin_version.sh
scarb publish --allow-dirty
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a hard requirement to set the version in snforge only for uploads? What are the downsides of having this set in repo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatic uploads to registry
6 participants